import java.util.*;
public class Test {
    private static String fab(int n) {
        if (n == 1) {
            return "0001";
        }
        long a = 1;
        long b = 1;
        long c = 0;
        while (n - 1 > 0) {
            if (a > 10000) {
                a %= 10000;
                b %= 10000;
                c %= 10000;
            }
            c = a + b;
            a = b;
            b = c;
            n--;
        }
        String str = null;
        str = c + "";
        String str1 = "";
        if (c > 9999) {


            for (int i = str.length() - 4; i < str.length(); i++) {
                str1 += str.charAt(i);
            }
            return str1;
        } else if (c > 999) {
            return str;
        } else {

            for (int i = 0; i < 4 - str.length(); i++) {
                str1 += "0";
            }
            str1 += c;
            return str1;
        }
    }

    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
                String str = fab(nums[i]);
                System.out.print(str);
            }
            System.out.println();
        }


    }

    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }

            if (n == 1) {
                System.out.print(1 + " " + 1);
                continue;
            }

            long i = 0;
            long x = 0;
            for (i = 4; i < 1000000000; i += 4) {
                int count = n;
                x = i;
                while (count > 0 && x % 4 == 0) {
                    x = x / 4 + x + 1;
                    count--;
                }
                if (count == 0) {
                    break;
                }
            }
            System.out.println(x + " " + (i + n));

        }
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();

            if(n == 0){
                break;
            }

            int count = 0;


            while(n > 1){
                count++;
                if(n == 3){
                    break;
                }

                if(n % 3 == 0){
                    n /= 3;
                }else if(n % 3 == 1){
                    n = n / 3 + 1;
                }else{
                    if(n == 2){
                        break;
                    }
                    n = n / 3 + 2;

                }

            }

            System.out.println(count);

        }
    }
}